class MaxArray {
    int findmax(int a[], int n) {
        int max = a[0];
        for (int i = 1; i < n; i++)
            if (a[i] > max)
                max = a[i];
        return max;
    }
}

public class MaxDemo {    public static void main(String avgs[])
    {
        MaxArray ob =new MaxArray();
        int a[]={2,5,7,3,18,9},b[]={33,43,6,12,8};
        System.out.println("数组a中的最大值是"+ob.findmax(a,6));
        System.out.println("数组b中的最大值是"+ob.findmax(b,b.length));
    }
}   
